Another action available on Flow is onStart(). This is called before the Flow starts emitting objects. You are passed a FlowCollector, which is the same object that is passed into the lambda expression of the flow() function. FlowCollector has the emit() function, and whatever your onStart() code emits is emitted by the Flow before any of the "real" entries.

So, in this case, in addition to ten random numbers from 0-100, we start the Flow with 1337.

You can learn more about this in:
Tags:
Run Edit